﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WpfSnqkGasAnalysis.IData;
using WpfSnqkGasAnalysis.Model;

namespace WpfSnqkGasAnalysis.IData_impl
{
    /// <summary>
    /// 数据接口实现。
    /// </summary>
    public class Clean_gas_update_logDAL_impl : BaseDAL, IClean_gas_update_logDAL
    {
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="cleanGasKEY">净化气主键id</param>
        /// <returns></returns>
        /// 创建时间：2022-12-14 10:45:13。作者：王浩力
        public List<Clean_gas_update_log> GetList(long cleanGasKEY)
        {
            string sql = " select  *  from  Clean_gas_update_log  where  jing_hua_qi_key=" + cleanGasKEY;
            return ExecSqlCmd(sql, null, c =>
            {
                var reader = c.ExecuteReader();
                if (!reader.HasRows)
                {
                    return null;
                }
                List<Clean_gas_update_log> list = new List<Clean_gas_update_log>();
                while (reader.Read())
                {
                    Clean_gas_update_log info = new Clean_gas_update_log();
                    DataLoadInField(reader, info);
                    list.Add(info);
                }
                return list;
            });

        }

        /// <summary>
        /// 将表字段读取的数据装入实体
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="info"></param>
        private static void DataLoadInField(System.Data.Common.DbDataReader reader, Clean_gas_update_log info)
        {
            info.Id = reader.GetInt64(0);
            info.Sample_no = reader["sample_no"].ToString();
            info.Well_name = reader["well_name"].ToString();
            info.Sampling_location = reader["sampling_location"].ToString();
            info.Air_source = reader["air_source"].ToString();
            info.Original_sampling_position = reader["original_sampling_position"].ToString();
            info.Net_sampling_position = reader["net_sampling_position"].ToString();
            info.Sampling_temperature = reader["sampling_temperature"].ToMyDecimal();
            info.Sampling_time = reader["sampling_time"].ToString();
            info.Analysis_time = reader["analysis_time"].ToString();
            info.Sampling_condiction = reader["sampling_condiction"].ToString();
            info.Sampling_user = reader["sampling_user"].ToString();
            info.Analysis_user = reader["analysis_user"].ToString();
            info.Analysis_company = reader["analysis_company"].ToString();

            info.Feedgas_percent = (decimal)reader["feedgas_percent"].ToMyDecimal();
            info.Feedgas_mg_per_m3 = (decimal)reader["feedgas_mg_per_m3"].ToMyDecimal();
            info.Clean_gas_percent = (decimal)reader["clean_gas_percent"].ToMyDecimal();
            info.Clean_gas_mg_per_m3 = (decimal)reader["clean_gas_mg_per_m3"].ToMyDecimal();

            info.Create_time = reader["create_time"].ToString();

            info.Update_real_name = reader["Update_real_name"].ToString();
            info.JIng_hua_qi_key = (long)reader["JIng_hua_qi_key"].ToString().ToMyDecimal();
            info.E_stat = (byte)reader["E_stat"].ToString().ToMyDecimal();
             
        }

    }
}
